const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const User = {};

const userSchema = new mongoose.Schema({
    _id: Schema.Types.ObjectId,
    password: String,
    name: String,
    createTime: Date,
    account: String,
    questions: [{
        type: Schema.Types.ObjectId,
        ref: 'questions'
    }]
})

User.Model = mongoose.model('users', userSchema);

User.Model.on('index', err => {
    if (err) {
        console.error('集合 keywords 索引错误！', err)
    } else {
        console.log('集合 users 索引成功...')
    }
})

module.exports = User;